package de.casino;

import java.util.Random;

public class Spin {

   private int           number;
   private static Random r = new Random();

   public Spin() {
      this.number = r.nextInt(36);
   }

   public Spin(int number) {
      this.number = number;
   }

   public int getNumber() {
      return number;
   }

   public void setNumber(int number) {
      this.number = number;
   }

   public Color getColor() {
      if (isZero()) {
         return Color.ZERO;
      } else if (isRed()) {
         return Color.RED;
      } else {
         return Color.BLACK;
      }
   }

   public boolean isRed() {
      switch (number) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 9:
      case 12:
      case 14:
      case 16:
      case 18:
      case 19:
      case 21:
      case 23:
      case 25:
      case 27:
      case 30:
      case 32:
      case 34:
      case 36:
         return true;
      default:
         return false;
      }
   }

   public boolean isBlack() {
      return !isRed() && !isZero();
   }

   public boolean isZero() {
      return number == 0;
   }

   @Override
   public String toString() {
      if (isZero()) {
         return Integer.toString(number);
      } else if (isRed()) {
         return number + " Rot";
      } else if (isBlack()) {
         return number + " Schwarz";
      }
      return super.toString();
   }

   public boolean isPair() {
      return !isZero() && number % 2 == 0;
   }

   public boolean isImpair() {
      return !isZero() && !isPair();
   }

   public boolean isLower() {
      return !isZero() && number < 19;
   }

   public boolean isHigher() {
      return !isZero() && !isLower();
   }

   public boolean isFirstColumn() {
      switch (number) {
      case 1:
      case 4:
      case 7:
      case 10:
      case 13:
      case 16:
      case 19:
      case 22:
      case 25:
      case 28:
      case 31:
      case 34:
         return true;
      default:
         return false;
      }
   }

   public boolean isMidColumn() {
      switch (number) {
      case 2:
      case 5:
      case 8:
      case 11:
      case 14:
      case 17:
      case 20:
      case 23:
      case 26:
      case 29:
      case 32:
      case 35:
         return true;
      default:
         return false;
      }
   }

   public boolean isLastColumn() {
      return !isZero() && !isFirstColumn() && !isMidColumn();
   }
}
